package com.google.code.timetrail.tests;

import junit.framework.TestCase;

import com.google.code.timetrail.backend.*;

/**
 * 
 * @author Anuraag Das
 *
 */
public class ItemTest extends TestCase{

	private Engine engineTested;
	private FluxCapacitor fluxCapacitorTested;
	private Food foodTested;
	private FuelCell fuelCellTested;
	private HullPart hullPartTested;
	private Money moneyTested;
	private TimeBulletBill timeBulletBillTested;
	private TimeSuit timeSuitTested;
	
	protected void setUp() throws Exception {
		engineTested = new Engine();
		fluxCapacitorTested = new FluxCapacitor();
		foodTested = new Food();
		fuelCellTested = new FuelCell();
		hullPartTested = new HullPart();
		moneyTested = new Money();
		timeBulletBillTested = new TimeBulletBill();
		timeSuitTested = new TimeSuit();		
	}
	
	public void testEngine() {
		assertEquals("Incorrect Weight",0,engineTested.getWeight());
		assertEquals("Incorrect Value",40,engineTested.getValue());
		assertEquals("Incorrect Max",10,engineTested.getMaxAmount());
		assertEquals("Incorrect Name","Engine",engineTested.getItemName());
		
		assertEquals("Incorrect Current Amount",0,engineTested.getCurrentAmount());
		assertEquals("Incorrect Addable Amount", true, engineTested.canAddCurrentAmount(5));
		assertEquals("Incorrect Current Amount",true,engineTested.canAddCurrentAmount(10));
		assertEquals("Incorrect Addable Amount", false, engineTested.canAddCurrentAmount(11));
		
		engineTested.setCurrentAmount(5);
		assertEquals("Incorrect Current Amount", 5, engineTested.getCurrentAmount());
		assertEquals("Incorrect Addable Amount",true,engineTested.canAddCurrentAmount(3));
		assertEquals("Incorrect Addable Amount",true,engineTested.canAddCurrentAmount(5));
		assertEquals("Incorrect Addable Amount",false,engineTested.canAddCurrentAmount(6));
		
		engineTested.setCurrentAmount(11);
		assertEquals("Incorrect Current Amount", 5, engineTested.getCurrentAmount());
		
		engineTested.addCurrentAmount(3);
		assertEquals("Incorrect Current Amount", 8, engineTested.getCurrentAmount());
		
		engineTested.addCurrentAmount(3);
		assertEquals("Incorrect Current Amount", 8, engineTested.getCurrentAmount());
		
		assertEquals("Incorrect Removable Amount", true, engineTested.canRemoveCurrentAmount(5));
		assertEquals("Incorrect Removable Amount", false, engineTested.canRemoveCurrentAmount(10));
	}
	
	public void testFlux() {
		assertEquals("Incorrect Weight",88,fluxCapacitorTested.getWeight());
		assertEquals("Incorrect Value",10,fluxCapacitorTested.getValue());
		assertEquals("Incorrect Max",5,fluxCapacitorTested.getMaxAmount());
		assertEquals("Incorrect Name","Flux Capacitor",fluxCapacitorTested.getItemName());
	}
	
	public void testFood() {
		assertEquals("Incorrect Weight",5,foodTested.getWeight());
		assertEquals("Incorrect Value",1,foodTested.getValue());
		assertEquals("Incorrect Max",Integer.MAX_VALUE,foodTested.getMaxAmount());
		assertEquals("Incorrect Name","Food",foodTested.getItemName());
	}
	
	public void testFuelCell() {
		assertEquals("Incorrect Weight",100,fuelCellTested.getWeight());
		assertEquals("Incorrect Value",10,fuelCellTested.getValue());
		assertEquals("Incorrect Max",5,fuelCellTested.getMaxAmount());
		assertEquals("Incorrect Name","Fuel Cell",fuelCellTested.getItemName());
	}
	
	public void testHull() {
		assertEquals("Incorrect Weight",125,hullPartTested.getWeight());
		assertEquals("Incorrect Value",10,hullPartTested.getValue());
		assertEquals("Incorrect Max",5,hullPartTested.getMaxAmount());
		assertEquals("Incorrect Name","Hull Part",hullPartTested.getItemName());
	}
	
	public void testMoney() {
		assertEquals("Incorrect Weight",0,moneyTested.getWeight());
		assertEquals("Incorrect Value",0,moneyTested.getValue());
		assertEquals("Incorrect Max",Integer.MAX_VALUE,moneyTested.getMaxAmount());
		assertEquals("Incorrect Name","Money",moneyTested.getItemName());
	}
	
	public void testTimeBulletBill() {
		assertEquals("Incorrect Weight",3,timeBulletBillTested.getWeight());
		assertEquals("Incorrect Value",2,timeBulletBillTested.getValue());
		assertEquals("Incorrect Max",Integer.MAX_VALUE,timeBulletBillTested.getMaxAmount());
		assertEquals("Incorrect Name","Time Bullet Bill",timeBulletBillTested.getItemName());
		assertEquals("Incorrect Current Bullets", 20, timeBulletBillTested.getCurrentBullets());
	}
	
	public void testTimeSuit() {
		assertEquals("Incorrect Weight",2,timeSuitTested.getWeight());
		assertEquals("Incorrect Value",10,timeSuitTested.getValue());
		assertEquals("Incorrect Max",Integer.MAX_VALUE,timeSuitTested.getMaxAmount());
		assertEquals("Incorrect Name","Time Suit",timeSuitTested.getItemName());
	}
} 
